package com.model.base;

import com.common.utils.StringUtils;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Entity基类
 * @author cat
 */
public class BaseEntity implements Serializable
{
    private static final long serialVersionUID = 1L;
    
    /** 请求参数 */
    @ApiModelProperty(hidden = true)
    private Map<String, Object> params;


    public Map<String, Object> getParams()
    {
        if (params == null)
        {
            params = new HashMap<>(1);
        }
        return params;
    }

    private void setParams(Map<String, Object> params)
    {
        this.params = params;
    }

    @ApiModelProperty(value = "排序字段")
    private String sortRow = "createdTime";

    @ApiModelProperty(value = "排序顺序desc,asc")
    private String sortOrder = "desc";

    @ApiModelProperty(value = "开始时间")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    private Date endTime;

    @ApiModelProperty(value = "page必须是正整数")
    @Range(min = 0, message = "page必须是正整数")
    private int page = 1;

    @ApiModelProperty(value = "pageSize必须是正整数")
    @Range(min = 0, message = "pageSize必须是正整数")
    private int pageSize = 10;

    @ApiModelProperty(value = "0:启用，1:停用，2:删除",allowableValues = "0,1,2,null")
    @Min(value = 0, message = "0:启用，1:停用，2:删除")
    @Max(value = 2, message = "0:启用，1:停用，2:删除")
    Byte isDelete = 0;

    public void setSortRow(String sortRow) {
        this.sortRow = sortRow;
    }

    public String getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(String sortOrder) {
        this.sortOrder = sortOrder;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public Byte getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Byte isDelete) {
        this.isDelete = isDelete;
    }

    public String getSortRow() {
        return StringUtils.camel4underline(this.sortRow) + " ";
    }


}
